<%@ Language=VBScript %>
<% Option Explicit %>
<% Response.Buffer = true %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<%
   Dim strQry, strName, arrQry, arrValues, x
   Dim Recipient, FromVar, DefFrom, DefSubject, DefRedirect
   Dim Body, objMailer
   
   strQry=Request.Form
   
   '<===============-------- Start of User Defined Variables --------================>
   
   Recipient = "vellacssr@earthlink.net"		'Where the message goes
   'Recipient = "donkuehn@gmail.com"			'Where the message goes

   DefFrom = "volsub@redemptoristretreat.org"		'Used if no response email
   DefSubject = "Volunteer Submission"			'Used if form doesn't have an element named subject
   DefRedirect = "ThankYouVol.htm"			'Used if form doesn't have an element named redirect
  
   ' <===============-------- End of User Defined Variables --------================>
   
   if len(Request.Form("Email"))>4 then
      DefFrom = Request.Form("Email")
   end if
   
   if len(Request.Form("Subject"))>0 then
      DefSubject = Request.Form("Subject")
   end if
   
   if len(Request.Form("Redirect"))>0 then
      DefRedirect = Request.Form("Redirect")
   end if
   
   if not(ValidEmail(Recipient)) then
      Response.Write " for Recipient<BR>"
      Response.End
   end if
   
   if not(ValidEmail(DefFrom)) then
      Response.Write " for sender (" & DefFrom & ")<BR>"
      Response.End
   end if
   
   'If we made it this far everything looks OK  so its time to process the
   'Form Elements and send the email
   
   arrQry = split(strQry,"&")
   Body = string(40,"-") & chr(10) & chr(13)
   for x = lbound(arrQry) to ubound(arrQry)
      arrValues = split(arrQry(x),"=")
      Body = Body & arrValues(0) & " = " & Request.Form(arrValues(0)) & chr(10) & chr(13)
   next
   
   'Response.Write Body
   'Set objMailer = CreateObject("CDONTS.Newmail")
   '   objMailer.From = DefFrom
   '   objMailer.To = Recipient
   '   objMailer.Subject = DefSubject
   '   objMailer.Body = Body
   '   objMailer.Send
   'Set objMailer = Nothing
   
	Set objMailer = CreateObject("CDO.Message")

	'This section provides the configuration information for the remote SMTP server.

	objMailer.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'Send the message using the network (SMTP over the network).
	objMailer.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="smtp.appliedi.net"
	objMailer.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
	objMailer.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False 'Use SSL for the connection (True or False)
	objMailer.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60

	' If your server requires outgoing authentication uncomment the lines bleow and use a valid email address and password.
	'objMailer.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'basic (clear-text) authentication
	'objMailer.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") ="somemail@yourserver.com"
	'objMailer.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="yourpassword"

	objMailer.Configuration.Fields.Update

	'End remote SMTP server configuration section==

	objMailer.To = Recipient
	objMailer.Subject = DefSubject
	objMailer.From = DefFrom

	' we are sending a text email.. simply switch the comments around to send an html email instead
	'objMailer.HTMLBody = Body
	objMailer.TextBody = Body

	objMailer.Send

	Set objMailer = Nothing

   
   
   
   
      
   if DefRedirect = "" then
      Response.Write "<H1 align=center>Thank You for your offer of help</H1>"
      Response.Write "<HR>"
      Response.Write "You should be hearing from us if we need your help<BR>"
      Response.Write "<P>&nbsp;<P>&nbsp;<P>&nbsp;<P>&nbsp;"
   else 
      Response.Redirect DefRedirect
   end if
   
%>

<%
   Function ValidEmail(Email)
      ValidEmail = true
      Dim Temp,Temp2
      if len(Email) > 100 then
         Response.Write "<br>Email address too long (" & Email & ")"
         ValidEmail = false
         Exit Function
      end if
      Email = LCase(Email)
      Temp = Split(Email,"@")
      if ubound(Temp) < 1 then
         Response.Write "<br>Email address not valid (" & Email & ")"
         ValidEmail = false
         Exit Function
      end if
      Temp2 = Split(Temp(1),".",-1,1)
      if ubound(Temp2) < 1 then
         Response.Write "<br>Email address not valid (" & Email & ")"
         ValidEmail = false
      end if
   End Function
%>

<BODY>
<P>&nbsp;</P>

</BODY>
</HTML>
